<template>
      <div>
         <!-- <makeOrgs></makeOrgs> -->
         <div v-if="makeShow == false"  >
              <makeFirst v-if="orgShow == false"  v-on:listenTochildFirstEvent='showMsgFirst'></makeFirst>
              <makeOrgs v-else v-on:listenTochildEvent="showMsgChild"></makeOrgs>
         </div>
         <maakeOne v-else></maakeOne>
          <!-- 自检弹窗 -->
          <div class="popUp" v-if="showPop == false" >
            <div class="popUpCenter">
                  <h4>{{popMessage}}</h4>
                  <el-button type="primary"  class="btn" @click="backPages" style="margin-left:330px;margin-top:10px;">确定</el-button>
            </div>
          </div>
      </div>
      
</template>
<script>
  import makeFirst from './makeIndex'
  import maakeOne from './makeOne'
  import makeOrgs from  './makeOrg'
  import {myselfCheck,makeSearch,orgMakeSearch} from "../api/getData";
import { setTimeout } from 'timers';
  export default {
        data:function(){
            return{
              popMessage:'',
              showPop:true,
              makeShow:true,
              parentMsg:'',
              codes:'',
              orgShow:true
            }
        },
        components:{makeFirst,maakeOne,makeOrgs},
        mounted:function(){
          var latticeid = JSON.parse(window.sessionStorage.getItem("latticeid"));
          makeSearch({"latticeId":latticeid}).then((data) => {
            console.log(data.data.code)
                if(data.data.code == 0){
                    this.makeShow = true
                }else{
                   this.makeShow = false
                   var organId  = JSON.parse(window.sessionStorage.getItem("organid"));
                    orgMakeSearch({ organId: organId }).then(data => {
                       
                        if(data.data.code == 0){
                            this.orgShow = true;
                        }else{
                            this.orgShow = false;
                        }
                    });
                     
                }
          })
          myselfCheck({"latticeId":latticeid}).then((data) => {
              console.log(data.data,'dcs')
              var message = data.data.msg.split('_')
              console.log(message)
              if(data.data.code == 0){
                 this.showPop = true;
              }else if(data.data.code == 1){

                        this.popMessage = message[1];
                        this.showPop = false
                       
              }
              this.codes = message[0];
          }).catch((error) => {
                 this.showPop = true;
          })
        },
        methods:{
           //自检确定返回上一页
            backPages(){

                if(this.codes == 2){
                    this.$router.push('/business/businessindex');
                    this.showPop = true;
                }else if(this.codes == 3 || this.codes == 4 || this.codes == 5){
                    this.$router.push('/windowss/windowssindex');
                    this.showPop = true;
                }else if(this.codes == 6){
                   this.$router.push('/equipment/equipmentindex');
                    this.showPop = true;
                }
                

                
            },
            showMsgChild:function(data){
             
              
              if(data == false){
                  this.orgShow = false
              }else{
                  this.makeShow = true
              }
            },
            showMsgFirst:function(data){
                this.makeShow = true
            }
        }
  }
</script>
<style lang='scss' scoped>
.popUp{
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 99;
      background: rgba(0,0,0,.5);
      display: flex;
      justify-content: center;
      align-items: center;
      .popUpCenter{
         width: 400px;
          font-size: 20px;
          color: #000;
          border-radius: 5px;
          text-align: left;
          line-height: 32px;
          background: #fff;
           padding: 30px;
          h4{
            font-size: 20px;
            color: #000;
            
            border-radius: 5px;
            text-align: left;
            line-height: 32px;
          }
          .btn{
            margin-left: 270px!important;
          }
      }
     
    }
</style>

